package com.example.myandroidapp.kotlin

/*
* 接口Interface：接口定义
* 1:类实现接口：class 类名:接口名{}、多实现用逗号隔开
* 2：类实现接口后，必须实现接口中的属性跟抽象方法，也得用override关键字修饰
*/

fun main() {
    var user = User("你大爷", 18)
    user.eat("翔翔")
    user.run()
}

interface IUser {
    var name: String
    var age: Int

    fun eat(food: String)
}

interface ISports {
    fun run()
}

class User(override var name: String, override var age: Int) : IUser, ISports {
    override fun eat(food: String) {
        println("${name + "年纪：" + age + "在吃" + food}")
    }

    override fun run() {
        println("${name + "年纪：" + age + "跑步如履平地"}")
    }
}